package interactiond

import (
	"time"

	cinteractiond "gogs.xiaoyuanjijiehao.com/antlinker/antcms/core/interactiond"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/ddd"
)

// @collname 互动类型集合(i_intType)
type collType struct {
	Code       string                 `bson:"_id"`        //编码
	Name       string                 `bson:"name"`       //名称
	Mode       cinteractiond.ITMode   `bson:"mode"`       //用户模式模式 0 累计计数 １ 取最后一次的值
	IsPublic   int                    `bson:"isPublic"`   //是否开放 0 不开放，1公开<br/>只有在Owner 和Org都为空时生效
	IsAgv      bool                   `bson:"isAgv"`      // 是否启用平均值
	Max        int                    `bson:"max"`        //最大分数
	Min        int                    `bson:"min"`        //最小分数
	Status     cinteractiond.ITStatus `bson:"status"`     //状态 0 初始化<br/> -1 删除 <br/>1 发布
	Creator    string                 `bson:"creator"`    //创建人
	CreTime    time.Time              `bson:"creTime"`    //创建时间
	DeleteTime time.Time              `bson:"deleteTime"` //删除时间
	Deleter    string                 `bson:"deleter"`    //删除人

}

func (c collType) CollID() string {
	return c.Code
}
func (collType) CollName() string {
	return collNameType
}
func (collType) IsCache() bool {
	return true
}
func (c *collType) FullDesc(e cinteractiond.TypeDesc) {
	c.Code = e.Code
	c.Name = e.Name
	c.Mode = e.Mode
	c.IsPublic = e.IsPublic
	c.IsAgv = e.IsAgv
	c.Max = e.Max
	c.Min = e.Min
	c.Status = e.Status

}
func (c collType) ToDesc() cinteractiond.TypeDesc {
	return cinteractiond.TypeDesc{
		Code:     c.Code,
		Name:     c.Name,
		Mode:     c.Mode,
		IsPublic: c.IsPublic,
		IsAgv:    c.IsAgv,
		Max:      c.Max,
		Min:      c.Min,
		Status:   c.Status,
	}
}

func (c *collType) FullOperator(e cinteractiond.Operator) {
	c.Creator = e.Creator
	c.CreTime = e.CreTime
	c.DeleteTime = e.DeleteTime
	c.Deleter = e.Deleter

}
func (c collType) ToOperator() cinteractiond.Operator {
	return cinteractiond.Operator{
		Creator:    c.Creator,
		CreTime:    c.CreTime,
		DeleteTime: c.DeleteTime,
		Deleter:    c.Deleter,
	}
}

func (c collType) ToAggregate() ddd.Aggregate {
	return c.ToTypeAggregate()
}
func (c collType) ToTypeAggregate() *cinteractiond.TypeAggregate {
	return &cinteractiond.TypeAggregate{
		TypeDesc: c.ToDesc(),
		Operator: c.ToOperator(),
	}
}
